#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<map>
using namespace std;
map<int, int> mp;
int main()
{
    int N, K, S;
    cin >> N >> K >> S;
    for (int i = 1; i <= S; i++)
    {
        int n, k;
        cin >> n >> k;
        mp[n] += k;
    }
    for (int i = 1; i <= S; i++)
    {
        if (mp[i] >= K)
            N--;
    }
    cout << N << endl;
    return 0;
}